﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Jzy.BLL.Mail;
using Jzy.Core.Common.Web;
using Frame.Lib.Common;
using Frame.Lib.Utilities;


public partial class WebMail_Account_List : PageList
{
    private WebMailAccountBO _mailAccount;
    protected void Page_Load(object sender, EventArgs e)
    {
        _mailAccount = new WebMailAccountBO(AppSession.UserID);
        if (!IsPostBack)
        {
            BindView();
        }
        AddAttr();
    }

    private void AddAttr()
    {
        JSUtil.ShowForm(lnkAdd, "增加账户", null, GlobalVar.WebCurrPath + "Edit.aspx", 550, 262);
    }

    private void BindView()
    {
        GVUtil.InitGV(gvList);
        gvList.EnableViewState = true;
        gvList.DataKeyNames = new string[] { "ID" };
        gvList.DataSource = _mailAccount.GetList();
        gvList.DataBind();
    }
    protected void btnRefresh_Click(object sender, EventArgs e)
    {
        BindView();
    }
    protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink lnkEdit = (HyperLink)e.Row.FindControl("lnkEdit");
            JSUtil.ShowForm(lnkEdit, "修改账户", null, GlobalVar.WebCurrPath + "Edit.aspx?ID=" + StrUtil.EncryptDES(gvList.DataKeys[e.Row.RowIndex]["ID"].ToString()), 550, 262);

            LinkButton btnDelete = (LinkButton)e.Row.FindControl("btnDelete");
            btnDelete.Attributes.Add("onclick", "return confirm('确认删除账户?');");
        }
    }
    protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        _mailAccount.Delete((int)gvList.DataKeys[e.RowIndex]["ID"]);
        BindView();
    }
}
